package com.fit.pages;

import java.util.Date;
import java.util.LinkedList;

import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.annotations.SetupRender;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.fit.enums.AccountRole;
import com.fit.interfaces.User;
import com.fit.service.Users;




/**
 * Start page of application example.
 */
public class Index
{
	@SessionState
	private User user;
	
	private boolean userExists;
	
	

//	@SetupRender
//	public void createObject(){
//		user.setBorrows(new LinkedList<Borrow>());
//	}

	public User getUser() {
		return user;
	}

	Object onActivate(){
		if(!userExists) return Login.class;
		if(user.getUserName() == "admin") return ConfirmAdministrator.class;
		else
		return null;
	}
	
	public boolean isUserAdmin(){
		if(user.getRole() == AccountRole.ADMINISTRATOR) return true;
		return false;
	}
	
	
	
	public boolean isUserAccount(){
		if(user.getRole() == AccountRole.USER) return true;
		return false;
	}
	
	

}
